package com.training.admin.dao;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;
import com.training.admin.entity.trainee.IdmUser;
import com.training.admin.entity.trainer.Trainer;
/**
 * @author xiaoHU
 *
 */
@Dao("hibernate")
public interface TrainerDao {

    /**
     * @param name
     * @return
     */
    @Query("FROM Trainer WHERE disabled = false AND code LIKE :code OR name LIKE :name OR email LIKE :email OR trainerType LIKE :trainerType")
    public List<Trainer> listBySearch(@Variable("code") String code, @Variable("name") String name, @Variable("email") String email, @Variable("trainerType") String trainerType);
    
    /**
     * 
     * @param userName
     * @return
     */
    @Query("FROM IdmUser WHERE usercn LIKE :userName")
    public List<IdmUser> loadByUserName(@Variable("userName") String userName);
    
    /**
     * 
     * @param userName
     * @return
     */
    @Query("FROM Trainer WHERE disabled = false AND email = :email")
    public Trainer loadByEmail(@Variable("email") String email);
}
